package com.yc.web.controller;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.Data;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

@Data
@Builder    // lombok 提供的注解， 将当前类生成一个构造器
@JsonInclude(NON_NULL)
public class ResponseResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public static ResponseResult ok(String message) {
        return ResponseResult.builder().code(1).msg(message).build();
    }

    public static ResponseResult ok() {
        return ResponseResult.builder().code(1).msg("成功").build();
    }

    public static ResponseResult error(String message){
        return ResponseResult.builder().code(0).msg(message).build();
    }

    public static ResponseResult error(){
        return ResponseResult.builder().code(0).msg("失败").build();
    }
    //放入Data的问题
    public  ResponseResult<T> setData(  T t ){
        this.data=t;
        return this;
    }
}
